﻿using SmartApi.Utils.Serialize;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace SmartApi
{
    public class ParseResponse : IParseResponse
    {
        private readonly ISerialize _serialize;

        public ParseResponse(ISerialize serialize)
        {
            _serialize = serialize;
        }
        public async Task<T> Parse<T>(RequestContext requestContext)
        {
            var contentStr = await requestContext.HttpResponse.Content.ReadAsStringAsync();
            return _serialize.Deserialize<T>(contentStr);
        }
    }
}
